﻿using DFGK_WMS.Model.DTO;
using DFGK_WMS.Model.Models;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.IRepository
{
    /// <summary>
    /// 出库
    /// </summary>
    public interface ITOutboundOrderDetailRepository : IBaseRepository<TShippingOrderDetail>
    {

        /// <summary>
        /// 获取出库单明细表数据
        /// </summary>
        /// <param name="criteria">筛选条件</param>
        /// <returns>返回实体对象</returns>
        TShippingOrderDetail GetShippingOrderDetail(int OrderId);
        /// <summary>
        /// 获取出库单明细
        /// </summary>
        /// <returns></returns>
        List<TShippingOrderDetail> GetTShippingOrderDetail(int pageIndex, int pageSize);
        /// <summary>
        /// 获取出库单明细  多个物料版本
        /// </summary>
        /// <returns></returns>
        List<TShippingOrderDetailPlusDTOGroup> GetTShippingOrderDetailPlus(int pageIndex, int pageSize);


        /// <summary>
        /// 根据垛条码查询垛主
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TStackingStorage> GetStackingStacker(string[] PalletBarcode);


        /// <summary>
        /// 首次提交，更新库存中状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int UpdStatus(int id);


        /// <summary>
        /// 根据ID查询入库垛信息
        /// </summary>
        /// <param name="PalletBarcode"></param>
        /// <returns></returns>
        List<TStackingStorage> GetStackingStorages(string[] PalletBarcode);

        /// <summary>
        /// 拣选出库
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        bool AddPickingOutbound(TPickingStationDatum item);

        /// <summary>
        /// 获取拣选出库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        List<TPickingStationDatum> GetPickingStationDatum(int id);

        /// <summary>
        /// 获取拣选出库详情
        /// </summary>
        /// <param name="PickingStationDataId"></param>
        /// <returns></returns>
        List<TPickingStationDataDetail> GetPickingStationDetail(int PickingStationDataId);

        /// <summary>
        /// 获取库存数量
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        decimal GetInventoryQuantity(int? MaterialId);

        /// <summary>
        /// 减去库存数量并修改库存状态
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        bool GetDwindleNumbers(TInventory inventory,decimal? num);

        /// <summary>
        /// 往库存流水表添加数据
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <returns></returns>
        bool AddInventoryFlow(SubmitOutListDTO OrderDTO);

        /// <summary>
        /// 提交出库执行
        /// </summary>
        /// <param name="id"></param>
        /// <param name="shippingOrderDetail"></param>
        /// <returns></returns>
        bool RunShippingOrderDetail(int id, TShippingOrderDetail shippingOrderDetail, out string message);


        /// <summary>
        /// 出库复核
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <returns></returns>
        bool SubmitOutInventoryReview(SubmitOutListDTO OrderDTO,out string message);

        bool SubmitOutInventoryReviewPlus(SubmitOutListDTO OrderDTO, out string message);


        /// <summary>
        /// 出库解绑
        /// </summary>
        /// <param name="palletBarcode"></param>
        /// <returns></returns>
        bool HandleUnbindOfOutstorage(SubmitOutListDTO OrderDTO , out string message);

        bool HandleUnbindOfOutstoragePlus(SubmitOutListDTO OrderDTO, out string message);



        /// 查询出库单相关数据
        List<CreateOutboundOrderDTO> GetOutboundOrder(string PalletBarcode);

        List<CreateOutboundOrderDTO> GetPalletBarcodePDA(int OrderDetailId);
        
        /// <summary>
        /// 出库方法 现用
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <param name="errorMsg"></param>
        /// <param name="isOutOver">出库单是否全部出库完成</param>
        /// <returns></returns>
        bool ChukuMsg(SubmitOutListDTONow OrderDTO, out string errorMsg,out bool isOutOver);

        /// <summary>
        /// 出库方法 现用 and 移库
        /// </summary>
        /// <param name="OrderDTO"></param>
        /// <param name="errorMsg"></param>
        /// <param name="isOutOver">出库单是否全部出库完成</param>
        /// <returns></returns>
        bool OutHouse(SubmitOutListDTONow OrderDTO, out string errorMsg, out bool isOutOver);
        /// <summary>
        /// 蒙牛一次性出完
        /// </summary>
        /// <param name="outHouseDTO"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>

        bool OutHousePro(OutHouseDTO outHouseDTO, out string errorMsg);
    }
}
